import BaseSdk from "./BaseSdk";
import { EnumplatFrom } from "./EnumplatFrom";
import SdkInterface from "./SdkInterface";
import TtSdk from "./TtSdk";
import WxSdk from "./WxSdk";


export default class SdkMgr {


    private sdkObj: SdkInterface = null;
    public constructor(sdkType: EnumplatFrom) {
        switch (sdkType) {
            case EnumplatFrom.TT:
                this.sdkObj = new TtSdk();
                break;
            case EnumplatFrom.WX:
                this.sdkObj = new WxSdk();
                break;
            default: //pc
                this.sdkObj = new BaseSdk();
                break;
        }
    }

    /**
     * 初始化
     * @param callback 初始化成功后回调
     * @param target 监听对象
     */
    public init(callback: Function, target: Object): void {
        this.sdkObj.init(callback, target);
    }

    /**
     * 登录
     * @param callback 登录成功后回调
     * @param target 监听对象
     */
    public login(): void {
        this.sdkObj.login();
    }

    /**
     * 登出
     */
    public logout(): void {
        this.sdkObj.logout();
    }

    /**
     * 退出
     */
    public exit(): void {
        this.sdkObj.exit();
    }

    /**
     * 切换账号
     */
    public switchLogin(): void {
        this.sdkObj.switchLogin();
    }

    /**
     * 数据上报
     * @param param 参数
     */
    public report(...param: any[]): void {
        this.sdkObj.report(param);
    }

    /**
     * 数据上报
     * @param param 参数
     */
    public pay(...param: any[]): void {
        this.sdkObj.pay(param);
    }

    /**
     * 主动拉起转发(小程序)
     */
    shareAppMessage(title: string = "", imageUrlId: string = "", imageUrl: string = "", query: any = null, shareCallback: any = null): void {
        this.sdkObj.shareAppMessage(title, imageUrlId, imageUrl, query, shareCallback);
    }
    /**获取小程序中的参数*/
    getAppParam(): any {
        const query = this.sdkObj.getAppParam();
        if (query) {
            console.log(`热启动参数:`, query)
        }
    }

    /**
     * 显示横幅广告
     * @param val 是否显示横幅广告，true 表示显示，false 表示隐藏
     * @returns 无返回值
     */
    showBannerAd(val: boolean): void {
        this.sdkObj.showBannerAd(val);
    }
    /**
     * 播放奖励广告
     *
     * @param callback 回调函数，用于处理广告播放结果
     * @param target 目标对象，可以是广告位标识或其他相关信息
     * @returns 无返回值
     */
    playRewardAd(callback, target): void {
        this.sdkObj.playRewardAd(callback, target);
    }
    /**重连 */
    reconnect(): void {
        this.sdkObj.reconnect();
    }
    navigateToScene(): void {
        this.sdkObj.navigateToScene();
    }
    getMenuButtonBoundingClientRect(): any {
        return this.sdkObj.getMenuButtonBoundingClientRect();
    }
    setImRankData(val: number): void {
        this.sdkObj.setImRankData(val);
    }
    getImRankList(): void {
        this.sdkObj.getImRankList();
    }
    vibrateShort(): void {
        this.sdkObj.vibrateShort();
    }
}